<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<script type="text/javascript">
	var sparepart = {
		gridId : "sparepartInDetailGrid",
		saveUrl : "sparepart/sparepartInDetail/save"
	};
</script>

<script type="text/javascript" src="js/widget/sparepart.js"></script>
<form:form id="sparepartInForm" commandName="model" cssClass="validate"
	action="sparepart/sparepartIn/save">
	<form:hidden path="id" />

	<table class=" form-table">
		<tr>
			<td class="td1">入库编号：</td>
			<td class="td2"><form:input path="code" disabled="true" /><span>
					(自动生成)</span>
			</td>
			<td class="td1">入库日期：</td>
			<td class="td2"><form:input type="date" path="instockDate"
					cssClass="required" />
			</td>
		</tr>
		<tr>
			<td class="td1">责任人：</td>
			<td class="td2" colspan="3"><form:input path="linkman" value="${creatorName }"
					cssClass="required" /></td>
		</tr>

		<%-- <tr>
			<td class="td1">入库类型：</td>
			<td class="td2" ><isperp:dictSelector
					typeCode="SPAREPART_IN_TYPE" name="inType" id="inType"
					hasEmptyValue="false" dictCssClass="required" dataWidth="260px"
					selectedValue="${model.inType }"></isperp:dictSelector>
			</td>
			<td class="td1">检测：</td>
		    <td class="td2" ><isperp:dictSelector
				typeCode="SPAREPART_CHECK" name="sptcheck" id="sptcheck"
				hasEmptyValue="false" dictCssClass="required" 
				selectedValue="${model.sptcheck }"></isperp:dictSelector></td>
		</tr> --%>
		<tr>
			<td class="td1">描述：</td>
			<td class="td2" colspan="3"><form:textarea path="memo"
					cssClass="required" /> </textarea></td>
		</tr>
		<tr>
			<td class="td1">填表人：</td>
			<td class="td2" colspan="3"><label>${creatorName }</label>
			</td>
		</tr>
	</table>

	<isperp:grid
		url="sparepart/sparepartInDetail/listBySparepartInId?sparepartInId=${model.id }"
		gridId="sparepartInDetailGrid" showPager="false" showSearchbar="false"
		cusDialogSize="big" editurl="sparepart/sparepartInDetail/save"
		cusDeleteUrl="sparepart/sparepartInDetail/delete"
		cusFormatterActions="true">
		<jsp:attribute name="toolbar">
		<isperp:toolbar id="iconToolbar">
			<isperp:button text="新增" icon="icon-plus"
					onclick="$('#sparepartSelector').click();"></isperp:button>
		</isperp:toolbar>
		</jsp:attribute>

		<jsp:body>
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="spt_code" title="编号" width="80">
		</isperp:column>
		<isperp:column name="treenode_name_path" title="备件分类" width="100">
		</isperp:column>
		<isperp:column name="spt_name" title="备件名称" width="150">
		</isperp:column>
		<isperp:column name="spt_model" title="规格型号" width="100">
		</isperp:column>
		<isperp:column name="spt_unit" title="单位" width="60">
		</isperp:column>
		<isperp:column name="quantity" title="数量" width="120"
				isFormatterFun="true"
				formatter="return getSpInputText(cellvalue, rowObject,2,1);">   
		</isperp:column>
		<isperp:column name="price" title="单价" width="120"
				isFormatterFun="true"
				formatter="return getSpInputText(cellvalue, rowObject,2,2);">   
		</isperp:column>
		<isperp:column name="memo" title="备注" width="120"
				isFormatterFun="true"
				formatter="return getSpInputText(cellvalue, rowObject,1);">   
		</isperp:column>
		
	</jsp:body>
	</isperp:grid>
</form:form>



<isperp:sparepartSelector relationId="${model.id }"
	gridId="sparepartInDetailGrid" formId="sparepartInForm"
	id="sparepartSelector"
	detailSaveUrl="sparepart/sparepartInDetail/saveDetails"></isperp:sparepartSelector>

<isperp:buttonList>
	<isperp:processButtons processKey="sparepartInProcess" beforeSubmit="function c(){return check();}"
		processId="${model.processId }" businessKey="${model.id }"
		formId="sparepartInForm"></isperp:processButtons>
</isperp:buttonList>
<script type="text/javascript">
function check()
{
    var o = jQuery("#sparepartInDetailGrid");
    var total = o.jqGrid('getGridParam', 'records');
   if(total>0)
   {
     return true;
   }else
   {
      isperp.alert("请添加入库备件！");
      return false;
   }
}
</script>

